package no.ntnu.fp.model1;

import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;

public class MWS{

	protected ArrayList<LWS> lwsList;
	private mwsGui gt;
	private int windowsUp = 0;
	private lwsGui lwsUp = null;
	private wellGui wellUp = null;
	private Comment commentUp = null;
	private String currentComment = "";
	
	public MWS(){
		lwsList = new ArrayList<LWS>();
		addLWS(1);
		addLWS(2);
		addLWS(3);
		addLWS(4);
		addLWS(5);
		addLWS(6);
		gt = new mwsGui(this);
	}
	
	public void reOpenWindows(){
		if(windowsUp == 0){
			//none up
			
		}else if(windowsUp == 1){
			//mws up
			
		}else if(windowsUp == 2){
			//lws only up
			lwsUp.createGui(gt);
		}else if(windowsUp == 3){
			//well+lws up
			lwsUp.createGui(gt);
			wellUp.createGui();
		}else if(windowsUp == 4){
			//comment+well+lws up
			lwsUp.createGui(gt);
			wellUp.createGui();
			commentUp.createGui(currentComment);
		}
	}
	
	private void addLWS(int id){
		LWS l = new LWS(id);
		lwsList.add(l);
		addSetOfWellsToLWS(l);
		System.out.println("La til LWS "+id);
	}
	
	private void addSetOfWellsToLWS(LWS l){
		int id = l.getLocalWatchSystemId();
		addWell(l, (id*10)+1);
		addWell(l, (id*10)+2);
		addWell(l, (id*10)+3);
		addWell(l, (id*10)+4);
		addWell(l, (id*10)+5);
		addWell(l, (id*10)+6);
	}
	
	private void addWell(LWS l, int id){
		Well well = new Well(l, id);
		l.addWell(well);
	}
	
	public static void main(String[] args){
		new MWS();
	}
}
